package balmysundaycandy.core.operations;

import com.google.appengine.repackaged.com.google.io.protocol.ProtocolMessage;
import com.google.appengine.repackaged.com.google.protobuf.GeneratedMessage;

/**
 * key object to get protocol buffer object.
 * 
 * @author marblejenka
 * 
 */
public class ProtocolBufferValue {

	ProtocolMessage<?> request;
	ProtocolMessage<?> response;
	
	ProtocolBufferValue(ProtocolMessage<?> request, ProtocolMessage<?> response) {
		this.request = request;
		this.response = response;
	}
	ProtocolBufferValue(GeneratedMessage.Builder<?> request,GeneratedMessage.Builder<?> response) {
		
	}

	public ProtocolMessage<?> cloneRequest(){
		return  request.clone();
	}
	
	public ProtocolMessage<?> cloneResponse(){
		return  request.clone();
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		if (!(obj instanceof ProtocolBufferValue)) {
			return false;
		}
		ProtocolBufferValue other = (ProtocolBufferValue) obj;
		return this.request.equals(other.request) && this.response.equals(other.response);
	}

	@Override
	public int hashCode() {
		return request.hashCode() * response.hashCode() * 27;
	}

}
